<?php
// +----------------------------------------------------------------------
// | HkCms
// +----------------------------------------------------------------------
// | Copyright (c) 2012-2019 http://www.hkcms.cn, All rights reserved.
// +----------------------------------------------------------------------
// | Author: 广州恒企教育科技有限公司 <admin@hkcms.cn>
// +----------------------------------------------------------------------

namespace app\admin\model;

use common\model\Model as CommModel;

class Urlrule extends CommModel
{	
	public $error  = '';

    /**
     * 创建管理员
     * @param type $data
     * @return boolean
     */
    public function add($data) 
    {

        if (empty($data)) {

            $this->error = '没有数据！';

            return false;
        }

        // 添加
        $id = $this->data($data)->allowField(true)->save();

        if ($id) {

            return $id;
        }

        $this->error = '入库失败！';

        return false;
    }

    public function edit($data)
    {
        if (empty($data)) {

            $this->error = '没有数据！';

            return false;
        }	

        $find = model('admin/Urlrule')->get(input('urlruleid'));

        if ( !$find ) {

        	$this->error = '数据不存在';

        	return false;
        }

        $result = $this->update($data);

        if (!$result) {

	        $this->error = '修改失败！';

	        return false;	
        }

        return $result;
    }
}